import Vue from 'vue'
import Vuex from 'vuex'

Vue.use(Vuex)

let store = new Vuex.Store({
    state: {
        title: '首页',
        NavBarItems: [
            {
                icon: "#iconshouye",
                name: "首页",
                path: 'shouye',
                style: {
                    'item-img-after': false
                }
            },
            {
                icon: "#iconhuihua",
                name: "会话",
                path: 'huihua',
                style: {
                    'item-img-after': false
                }
            },
            {
                icon: "#iconfangke",
                name: "访客",
                path: 'fangke',
                style: {
                    'item-img-after': false
                }
            },
            {
                icon: "#iconlishi",
                name: "历史",
                path: 'lishi',
                style: {
                    'item-img-after': false
                }
            },
            {
                icon: "#iconkehu",
                name: "客户",
                path: 'kehu',
                style: {
                    'item-img-after': false
                }
            },
            {
                icon: "#icongongdan",
                name: "工单",
                path: 'gongdan',
                style: {
                    'item-img-after': false
                }
            },
            {
                icon: "#icontongji",
                name: "统计",
                path: 'tongji',
                style: {
                    'item-img-after': false
                }
            },
            {
                icon: "#iconshezhi",
                name: "设置",
                path: 'shezhi',
                style: {
                    'item-img-after': false
                }
            },
            {
                icon: "#icontuichu",
                name: "退出",
                path: 'tuichu',
                style: {
                    'item-img-after': false
                }
            }
        ],
    },
    mutations: {
        NavStyleClear(state, payload) {
            console.log(state)
            console.log(payload)
            for (let i in state.NavBarItems) {
                state.NavBarItems[i].style['item-img-after'] = false
                if (state.NavBarItems[i].name === payload) {
                    state.NavBarItems[i].style['item-img-after'] = true
                }
            }
        },
        setTitle(state, payload) {
            state.title = payload
        }
    }
})

export default store